#pragma once

#include <memory>

namespace TrueText {

class StreamImpl;

class Stream 
{
public:
	virtual StreamImpl* getImpl() = 0;
    virtual ~Stream() {}
};

// This stream doesn't create a copy of given memory thus leaving face objects created 
// from it dependent on that memory.
class MemoryStream : public Stream
{
public:
	MemoryStream(void* ptr, size_t sz);
    ~MemoryStream();

public:
	virtual StreamImpl* getImpl();

private:
	std::auto_ptr<StreamImpl> impl;
};

class CachingMemoryStreamImpl;

class CachingMemoryStream : public Stream
{
public:
	CachingMemoryStream(void* ptr, size_t sz);
	CachingMemoryStream(size_t sz);
	~CachingMemoryStream();

	void* GetBuffer();

public:
	virtual StreamImpl* getImpl();

private:
	void* ptr;
	size_t sz;
	std::auto_ptr<CachingMemoryStreamImpl> impl;
};

}